const app = getApp()
Component({
  properties: {
    types: {
      type: String,
      value: ''
    },
    title: {
      type: String,
      value: ''
    },
    message: {
      type: String,
      value: ''
    },
    //中间弹框图片
    showMiddleModalImg: {
      type: String,
      value: ''
    },
    list: {
      type: Array,
      value: []
    },
    showTitle: {
      type: Boolean,
      value: false
    },
    /**
     * 是否来自tabbar
     */
    fromTabbar: {
      type: Boolean,
      value: false
    }
  },

  data: {
    isShowModal: false,
    selectIndex: '',
    selectItem: '',
    selectLabel: ''
  },

  methods: {
    /**
     * 点击确认选择
     * @param {*} item
     */
    clickItem(item) {
      this.setData({
        selectIndex: item.currentTarget.dataset.index
      })
      this.setData({
        selectItem: this.data.list[
          item.currentTarget.dataset.index
        ].key
      })
      this.setData({
        selectLabel: this.data.list[
          item.currentTarget.dataset.index
        ].label
      })
    },
    clickTest() {},
    //点击确定
    onClickConfirm() {
      const data = this.data
      this.triggerEvent('onConfirm', data)
      //return
      this.onClickHideModal()
    },
    onClickShowModal() {
      if (app.globalData.showModel) {
        return
      }
      app.globalData.showModel = true
      this.setData({
        isShowModal: true
      })
    },
    onClickHideModal() {
      this.setData({
        isShowModal: false
      })
      app.globalData.showModel = false
    }
  }
})